package model.commands.booleans;

import java.util.List;
import model.Environment;
import model.SyntaxErrorException;
import model.commands.Command;


/**
 * Name:
 * AND test1 test2
 * 
 * Description:
 * returns 1 if test1 and test2 are non-zero, otherwise 0
 * 
 * @author JLongley
 * @author Erick Gonzalez
 */
public class AndCommand extends Command {

    @Override
    public int evaluate(Environment e) throws SyntaxErrorException {
        List<Command> myArguments = getArguments();
        boolean myAnd = true;
        for (Command arg : myArguments) {
            myAnd = myAnd && arg.evaluate(e) != 0;
        }
        return myAnd ? 1 : 0;
    }
}
